home *** CD-ROM | disk | FTP | other *** search
- Path: informatik.uni-bremen.de!news
- From: thuerman@informatik.uni-bremen.de (Urs Thuermann)
- Newsgroups: comp.lang.c++
- Subject: overloading and ellipsis
- Date: 28 Mar 1996 17:49:57 +0100
- Organization: Universitaet Bremen, Germany.
- Message-ID: <tuka05p3gq.fsf@twit.informatik.uni-bremen.de>
- NNTP-Posting-Host: twit.informatik.uni-bremen.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
- Follow-Up: comp.lang.c++,poster
- X-Newsreader: Gnus v5.0.10
-
- I'd like to overload a function with ellipsis but g++ doesn't let me
- do that. Should that be possible?
-
- void send(char *fmt, ...)
- {
- ;
- }
-
- void send(char *fmt, va_list)
- {
- ;
- }
-
- void send(char *s)
- {
- ;
- }
-
- main()
- {
- va_list ap;
-
- send("abc %d\n", 13); // ok, calls first function
-
- send("abc %d\n", ap); // ok, calls second function
-
- send("abc\n"); // error: ambiguous
- }
-
- The second call is ok, because the argument ap does match better to
- va_list than to "...", according to ARM r.13.2
-
- [5] Match with ellipsis: Sequences that involve matches with
- ellipsis are worse than all others.
-
- This, of course sequences of conversion, so it doesn't apply to the
- third call in my example where no conversion is neccessary.
- But nevertheless I would think that the third function matches better
- than the first for the third call in main(), so there would be exactly
- one best match and the call legal.
- Does the ARM say something about this, and is g++ correct?
-
- Please also answer me by email.
-
- urs
-